<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h3>事件</h3>
      <!-- v-on指令用于定义事件 -->
      <!-- handleClick是事件处理函数 -->
      <!-- 括号是可以加也可以不加的 -->
      <!-- 不加的时候有默认参数event -->
      <button v-on:click="handleClick()">btn</button>
      <p v-if="show">hello</p>
      <input type="text" v-on:input="handleInput(8, $event)" />
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          show: true,
        },
        // methods里面就是定义事件处理函数的
        methods: {
          handleClick() {
            // console.log("hello");
            this.show = !this.show;
          },
          handleInput(num, e) {
            // console.log("input");
            console.log(num);
            console.log(e.target.value);
          },
        },
      });
    </script>
  </body>
</html>
